<template>
  <el-form ref="scriptForm" :model="request" label-width="100px" style="height: 500px">
    <div v-show="oneShow">
      <h2 style="text-align: center">第一页参数</h2>
      <el-button type="primary" @click="execute">过滤属性</el-button>
      <el-button type="primary" @click="oneShow=false;twoShow=true">下一步</el-button>
      <el-row :gutter="20">
        <el-col>
          <el-form-item label="质量等级" prop="qualitygrade">
            <el-radio-group v-model="request.qualitygrade">
              <el-radio v-for="(item, index) in form.qualitygrade" :label="item" :key="index">{{ item }}</el-radio>
              <el-radio label="">清除</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="总线通信类型" prop="cpuInterface">
            <el-radio-group v-model="request.cpuInterface">
              <el-radio v-for="(item, index) in form.cpuInterface" :label="item" :key="index">{{ item }}</el-radio>
              <el-radio label="">清除</el-radio>
            </el-radio-group>
<!--            <el-select clearable v-model="request.cpuInterface" placeholder="请选择总线通信类型"  size="small">-->
<!--              <el-option v-for="(item, index) in form.cpuInterface" :label="item" :value="item" :key="index"/>-->
<!--            </el-select>-->
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="电压等级" prop="inVoltage">
            <el-radio-group v-model="request.inVoltage">
              <el-radio v-for="(item, index) in form.inVoltage" :label="item" :key="index">{{ item }}</el-radio>
              <el-radio label="">清除</el-radio>
            </el-radio-group>
<!--            <el-select clearable v-model="request.inVoltage" placeholder="请选择电压等级"  size="small">-->
<!--              <el-option v-for="(item, index) in form.inVoltage" :label="item" :value="item" :key="index"/>-->
<!--            </el-select>-->
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col >
          <el-form-item label="处理器类型" prop="controller">
            <el-radio-group v-model="request.controller">
              <el-radio v-for="(item, index) in form.controller" :label="item" :key="index">{{ item }}</el-radio>
              <el-radio label="">清除</el-radio>
            </el-radio-group>
<!--            <el-select clearable v-model="request.controller" placeholder="请选择处理器类型"  size="small">-->
<!--              <el-option v-for="(item, index) in form.controller" :label="item" :value="item" :key="index"/>-->
<!--            </el-select>-->
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="最大功率" prop="maxPower">
            <el-input v-model="request.maxPower" placeholder="最大功率" style="width: 200px"/>
            <span class="sub-title">{{form.maxPower}}</span>
          </el-form-item>
        </el-col>
      </el-row>

    </div>

    <div v-show="twoShow">
      <h2 style="text-align: center">模拟通道参数</h2>
      <el-button type="primary" @click="execute2">过滤属性2</el-button>
      <el-button type="primary" @click="twoShow=false;threeShow=true">下一步</el-button>
      <el-button type="primary" @click="twoShow=false;oneShow=true">上一步</el-button>
      <el-form-item label="采集型号类型" prop="signalType">
        <el-radio-group v-model="request.signalType">
          <el-radio v-for="(item, index) in form.signalType" :label="item" :key="index">{{ item }}</el-radio>
          <el-radio label="">清除</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="最低频率" prop="fMin">
            <el-input v-model="request.fMin" placeholder="最低频率" style="width: 200px"/>
            <span class="sub-title">{{ form.fMin }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="最高频率" prop="fMax">
            <el-input v-model="request.fMax" placeholder="最低频率" style="width: 200px"/>
            <span class="sub-title">{{ form.fMax }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="最小值" prop="inputMinRange">
            <el-input v-model="request.inputMinRange" placeholder="最小值" style="width: 200px"/>
            <span class="sub-title">{{ form.inputMinRange }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="最大值" prop="inputMaxRange">
            <el-input v-model="request.inputMaxRange" placeholder="最大值" style="width: 200px"/>
            <span class="sub-title">{{ form.inputMaxRange }}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col>
          <el-form-item label="采样率" prop="sample">
            <el-input v-model="request.sample" placeholder="采样率" style="width: 200px"/>
            <span class="sub-title">{{ form.sample }}</span>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="采样分辨率" prop="numberOfDigits">
            <el-radio-group v-model="request.numberOfDigits">
              <el-radio v-for="(item, index) in form.numberOfDigits" :label="item" :key="index">{{ item }}</el-radio>
              <el-radio label="">清除</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="采样长度" prop="sample">
            <el-input v-model="request.samplingLength" placeholder="采样长度" style="width: 200px"/>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="模拟参数页码" prop="analoguePage">
            <el-input v-model="request.analoguePage" placeholder="模拟参数页码" style="width: 200px"/>
          </el-form-item>
        </el-col>
      </el-row>

    </div>

    <div v-show="threeShow">
      <h2 style="text-align: center">数字通道参数</h2>
      <el-button type="primary" @click="execute3">过滤属性3</el-button>
      <el-button type="primary" @click="threeShow=false;fourShow=true">下一步</el-button>
      <el-button type="primary" @click="threeShow=false;twoShow=true">上一步</el-button>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="数字信号类型" prop="inType" style="width: 500px">
            <el-radio-group v-model="request.inType">
              <el-radio v-for="(item, index) in form.inType" :label="item" :key="index">{{ item }}</el-radio>
              <el-radio label="">清除</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item label="输入信号电压" prop="sample">
            <el-input v-model="request.inputVoltageRange" placeholder="输入信号电压" style="width: 200px"/>
            <span class="sub-title">{{ form.inputVoltageRange }}</span>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="数字参数页码" prop="digitalPage">
            <el-input v-model="request.digitalPage" placeholder="数字参数页码" style="width: 200px">2.1</el-input>
          </el-form-item>
        </el-col>
      </el-row>


    </div>

    <div v-show="fourShow">
      <h2 style="text-align: center">参数检查</h2>
      <el-button type="primary" @click="fourShow=false;threeShow=true">上一步</el-button>
      <el-button type="primary" @click="go">生成方案</el-button>
      <el-button type="primary" @click="getData">获取数据</el-button>
      <el-row :gutter="20" style="margin-bottom: 8px">
        <el-col :span="5" ><el-card  shadow="hover">质量等级：{{ request.qualitygrade }}</el-card></el-col>
        <el-col :span="5"><el-card  shadow="hover">总线通信类型：{{ request.cpuInterface }}</el-card></el-col>
        <el-col :span="5"><el-card  shadow="hover">电压等级：{{ request.inVoltage }}</el-card></el-col>
        <el-col :span="5"><el-card  shadow="hover">处理器的类型：{{ request.controller }}</el-card></el-col>
        <el-col :span="4"><el-card  shadow="hover">最大功率：{{ request.maxPower }}</el-card></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-bottom: 8px">
        <el-col :span="6"><el-card  shadow="hover">采集类型：{{ request.signalType }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">最小频率：{{ request.fMin }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">最大频率：{{ request.fMax }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">最小输入范围：{{ request.inputMinRange }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">最大输入范围：{{ request.inputMaxRange }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">采样率：{{ request.sample }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">采样分辨率：{{ request.numberOfDigits }}</el-card></el-col>
        <el-col :span="6"><el-card  shadow="hover">采样长度：{{ request.samplingLength }}</el-card></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-bottom: 8px">
        <el-col :span="12"><el-card  shadow="hover">数字电路类型：{{ request.inType }}</el-card></el-col>
        <el-col :span="12"><el-card  shadow="hover">输入信号电压：{{ request.inputVoltageRange }}</el-card></el-col>
      </el-row>

      <el-form-item label="输出数据" prop="value2">
        <el-input v-model="value2" type="textarea" placeholder="请输入内容" style="resize: none"/>
      </el-form-item>

      <el-form-item label="id" prop="id">
        <el-input v-model="id" type="textarea" placeholder="请输入内容" style="resize: none"/>
      </el-form-item>
    </div>


  </el-form>
</template>

<script>
  import { execute, circuitGeneration, getCircuitData } from "@/api/expert/circuitType";
  import vueJsonEditor from 'vue-json-editor'
  export default {
    name: "test2",
    components:{vueJsonEditor},
    created() {
      this.execute()
    },
    data() {
      return {
        // 属性列表
        attributeList: [],
        // 属性模板列表
        attributeTemplateList: [],
        // 电路信息
        circuitData: {},
        // 枚举类型
        dataTypeEnum: this.GlobalVariable.dataTypeEnum,
        // 数据类型
        dataType: '',

        value2:'',
        id:'',


        form: {},

        request: {},

        tipsParam:{
          qualitygrade:"", // 质量等级
          cpuInterface:"", // 总线通信类型
          inVoltage:"",  // 电压等级
          controller:"", // 处理器的类型
          maxPower:"", // 最大功率
          signalType:"", // 采集类型
          fMin:"", // 最小频率
          fMax:"", // 最大频率
          inputMinRange:"", // 最小输入范围
          inputMaxRange:"", // 最大输入范围
          sample:"", // 采样率
          numberOfDigits:"", // 采样分辨率
          samplingLength:"",  // 采样长度
          inType:"", // 数字电路类型
          inputVoltageRange:"" // 输入信号电压
        },

        oneShow: true,
        twoShow: false,
        threeShow: false,
        fourShow: false

      }
    },
    mounted() {


    },
    methods: {
      execute(){
        const tp = {}
        tp.qualitygrade = this.request.qualitygrade
        tp.bus = this.request.cpuInterface
        tp.volt = this.request.inVoltage
        tp.controller = this.request.controller
        tp.power = this.request.maxPower
        tp.page = 1
        execute({"param": JSON.stringify(tp),"mainProjectId":"123"}).then(res =>{
          const jpd = JSON.parse(res.data)
          this.tipsParam.qualitygrade = jpd.qualitygrade
          this.tipsParam.cpuInterface = jpd.bus
          this.tipsParam.inVoltage = jpd.volt
          this.tipsParam.controller = jpd.controller
          this.tipsParam.maxPower = jpd.power
          this.tipsParam.signalType = jpd.analoguetype
          this.tipsParam.fMin = jpd.signalmin
          this.tipsParam.fMax = jpd.signalmax
          this.tipsParam.inputMinRange = jpd.mindatarange
          this.tipsParam.inputMaxRange = jpd.maxdatarange
          this.tipsParam.sample = jpd.sample
          this.tipsParam.numberOfDigits = jpd.samplingbit
          this.tipsParam.samplingLength = jpd.samplinglength
          this.tipsParam.inType = jpd.intype
          this.tipsParam.inputVoltageRange = jpd.involt
          this.form = this.tipsParam
        })
      },
      execute2(){
        const tp = {}
        tp.qualitygrade = this.request.qualitygrade
        tp.bus = this.request.cpuInterface
        tp.volt = this.request.inVoltage
        tp.controller = this.request.controller
        tp.power = this.request.maxPower
        tp.analoguetype = this.request.signalType
        tp.signalmin = this.request.fMin
        tp.signalmax = this.request.fMax
        tp.mindatarange = this.request.inputMinRange
        tp.maxdatarange = this.request.inputMaxRange
        tp.sample = this.request.sample
        tp.samplingbit = this.request.numberOfDigits
        tp.samplingLength = this.request.samplingLength
        tp.page = this.request.analoguePage
        execute({"param": JSON.stringify(tp),"mainProjectId":"123"}).then(res =>{
          const jpd = JSON.parse(res.data)
          this.tipsParam.signalType = jpd.analoguetype
          this.tipsParam.fMin = jpd.signalmin
          this.tipsParam.fMax = jpd.signalmax
          this.tipsParam.inputMinRange = jpd.mindatarange
          this.tipsParam.inputMaxRange = jpd.maxdatarange
          this.tipsParam.sample = jpd.sample
          this.tipsParam.numberOfDigits = jpd.samplingbit
          this.tipsParam.samplingLength = jpd.samplinglength
          this.form = this.tipsParam

        })
      },
      execute3(){
        const tp = {}
        tp.qualitygrade = this.request.qualitygrade
        tp.bus = this.request.cpuInterface
        tp.volt = this.request.inVoltage
        tp.controller = this.request.controller
        tp.power = this.request.maxPower
        tp.intype = this.request.inType
        tp.involt = this.request.inputVoltageRange
        tp.page = this.request.digitalPage
        execute({"param": JSON.stringify(tp),"mainProjectId":"123"}).then(res =>{
          const jpd = JSON.parse(res.data)
          this.tipsParam.inType = jpd.intype
          this.tipsParam.inputVoltageRange = jpd.involt
          this.form = this.tipsParam
        })
      },

      go(){
        let json = {
          "bus":{"code":this.request.cpuInterface,"name":"数据总线接口类型（处理器接口）"},
          "volt":{"code":this.request.inVoltage,"name":"供电电压（电源输入电压）"},
          "analoguenum":{"code":1,"name":"模拟采样通道数量"},
          "digitalnum":{"code":1,"name":"数字采样通道数量"},
          "controller":{"code":this.request.controller,"name":"处理器类型"},
          "prior":{"code":"balance","name":"设计考虑"},
          "qualitygrade":{"code":this.request.qualitygrade,"name":"质量等级"},
          "power":{"code":this.request.maxPower,"name":"最大功率（电源最大功率）"},
          "analogue":[{
            "analogueno":{"code":1,"name":"第一通道"},
            "analoguename":{"code":"v1","name":"通道名称"},
            "analoguetype":{"code":this.request.signalType,"name":"通道采集类型（电压：1、温度：4）"},
            "sample":{"code":this.request.sample,"name":"采样率"},
            "signalmax":{"code":this.request.fMax,"name":"最高频率"},
            "signalmin":{"code":this.request.fMin,"name":"最低频率"},
            "maxdatarange":{"code":this.request.inputMaxRange,"name":"最大输入"},
            "mindatarange":{"code":this.request.inputMinRange,"name":"最小输入"},
            "samplingbit":{"code":this.request.numberOfDigits,"name":"采样精度"},
            "samplinglength":{"code":this.request.samplingLength,"name":"采样长度"}
          }],
          "digital":[{
            "digitalno":{"code":1,"name":"第一通道"},
            "digitalname":{"code":"d1","name":"通道名称"},
            "intype":{"code":this.request.inType,"name":"源型"},
            "involt":{"code":this.request.inputVoltageRange,"name":"信号电压"}
          }],
          circuitIds: "123"
        };


        circuitGeneration({"param": JSON.stringify(json)}).then(res =>{
          this.value2 = JSON.stringify(res.data)
        })

      },

      getData(){
        getCircuitData({"id": this.id}).then(res =>{
          this.value2 = JSON.stringify(res.data)
        })
      }


    }
  }
</script>

<style scoped>

</style>
